package my.fuelwallet.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class ViewProfile extends Activity {
	private CarProfileHandle profiles;
	private String accountName;
	
	public void onCreate(Bundle savedInstanceState) { 
		super.onCreate(savedInstanceState); 
		setContentView(R.layout.view_profile);
		
		Bundle bundle = getIntent().getExtras();
		accountName = bundle.getString("accountName");
		
		profiles = new CarProfileHandle(this);
        profiles.open();
        CarProfile cp = profiles.getCarProfile(accountName);
        
        TextView vAccountName = (TextView)findViewById(R.id.vAccountName);
        TextView vFuelType = (TextView)findViewById(R.id.vFuelType);
        TextView vDisplacement = (TextView)findViewById(R.id.vDisplacement);
        
        vAccountName.setText("Account Name: " + cp.getAccountName());
        vFuelType.setText("FuelType: " + cp.getFuelName());
        vDisplacement.setText("Displacement: " + Float.toString(cp.getDisplacement()));
        
        profiles.close();
		
	}
	
	public void onClick(View view) {
    	switch (view.getId()) {
    	case R.id.delete_profile:
            profiles.open();
            profiles.deleteCarProfile(accountName);
            profiles.close();
    		Intent intent = new Intent(ViewProfile.this, CarProfileManagerActivity.class );
    		startActivity(intent);
    		break;
    		
    	/*case R.id.edit_profile:
            profiles.open();
            profiles.deleteCarProfile(accountName);
            profiles.close();
            Intent intent2 = new Intent(ViewProfile.this, AddProfile.class );
    		startActivity(intent2);
    		break;*/
    		
    	}
    	finish();
    }
}